<template lang="html">
    <div class="Cart_box">
        <div class="Cart_header">
            <div class="Cart_header-one">购物车</div>
            <div class="Cart_header-two">
                <p>12345678911</p>
                <p>龙山跃（便民超市）</p>
            </div>
        </div>
        <div class="Cart_main-No-hide" v-if="isShow">
            <div class="Cart_main-No">
                <img src="../assets/Cart_banner.png" alt="">
                <div class="Cart_main-No-go">
                    <span class="Cart_main-No-go-yellow"><router-link to="/home/">去逛逛</router-link></span>
                    <span>领券去！</span>
                </div>
            </div>
        </div>
        <div class="Cart_main-Yes" v-else>
            <span class="Cart_main-Yes-header-edit">
                <a>编辑</a>
                <a>取消</a>
            </span>
            <div class="Cart_main-Yes-shoping">已选商品</div>
            <dl class="Cart_main-Yes-commodity" v-for="x in items">
                <dt>
                    <img :src="x.icon" alt="">
                </dt>
                <dd class="Cart_main-Yes-commodity-details">
                    <div class="Cart_main-Yes-commodity-content">
                        <p class="Cart_main-Yes-commodity-name">{{x.main_name}}</p>
                        <p>{{x.title}}</p>
                    </div>
                    <div class="Cart_main-Yes-commodity-money">
                        <p><span class="Cart_main-Yes-commodity-price">{{x.price}}</span>/份</p>
                        <p class="Cart_main-Yes-commodity-style">劲爆超值</p>
                    </div>
                </dd>
                <dd class="Cart_main-Yes-commodity-allNum">
                    <a class="Cart_main-Yes-commodity-minus" @click="clickMinus(x)">-</a>
                    <a class="Cart_main-Yes-commodity-num">{{x.count}}</a>
                    <a class="Cart_main-Yes-commodity-add" @click="clickAdd(x)">+</a>
                </dd>
            </dl>
        </div>
        <div class="Cart_footer-frams">
            <div class="Cart_footer">
                <div class="Cart_footer-money">{{"￥" + moneySum}}</div>
                <div class="Cart_footer-pay">去结算</div>
            </div>
        </div>
    </div>
</template>
<script>
import eventHub from '../router/bus.js';
export default{
    data () {
        return {
            items : eventHub.todos,
            todosName : eventHub.todosName,
            numAll : eventHub.numAll,
            moneySum :eventHub.money,
            isShow : eventHub.isShow
        }
    },
    components: {eventHub},
    methods : {
        clickMinus : function (x) {
            eventHub.$emit("minus",x);
            if(this.numAll.length == 0){
                document.querySelector(".footer_allNum").style.display = "none"
                this.isShow = true
            }
        },
        clickAdd : function (x) {
            eventHub.$emit("add",x);
        }
    },
}
</script>
<style lang="css">
    .Cart_box{
        background: #f5f6f8;
        height: 100vh;
    }
    .Cart_header{
        width: 100%;
        height: 5.75rem;
        background: white;
    }
    .Cart_header-one{
        width: 100%;
        height: 3rem;
        border-bottom: 1px solid #cacaca;
        box-sizing: border-box;
        text-align: center;
        font: 1rem/3rem "微软雅黑";
        color: #424644;
    }
    .Cart_header-two{
        width: 100%;
        height: 2.75rem;
        border-bottom: 1px solid #cacaca;
        padding: 0.4rem 0 0.3rem 0.5rem;
        box-sizing: border-box;
        background: #ffc000;
    }
    .Cart_header-two p{
        width: 100%;
        height: 50%;
        font: 0.8rem/0.8rem "微软雅黑";
        color: #424644;
    }
    .Cart_header-two p:last-of-type{
        padding-top: 0.2rem;
        box-sizing: border-box;
    }
    /*无货时*/
    .Cart_main-No{
        width: 100%;
        height: 12.25rem;
        padding-top: 2.25rem;
        box-sizing: border-box;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        align-items: center;
    }
    .Cart_main-No img{
        width: 5.6rem;
        height: 7.4rem;
    }
    .Cart_main-No-go{
        font-size: 0.8rem;
        color: #424644;
    }
    .Cart_main-No-go span{
        padding: 0.2rem 0.5rem;
        border: 1px solid #424644;
        margin: 0 0.1rem;
        border-radius: 0.3rem;
    }
    .Cart_main-No-go .Cart_main-No-go-yellow{
        border: 1px solid #ffc000;
        color: #ffc000;
        padding: 0.2rem 0.8rem;
    }
    /*有货时*/
    .Cart_main-Yes-header-edit{
        display: inline-block;
        height: 3rem;
        position: absolute;
        top: 0;
        right: 0;
        padding-right: 1rem;
        box-sizing: border-box;
    }
    .Cart_main-Yes-shoping{
        width: 100%;
        height: 2.6rem;
        padding: 0.65rem;
        box-sizing: border-box;
        font: 0.95rem/0.95rem "微软雅黑";
        color: #000;
    }
    .Cart_main-Yes-header-edit>a{
        font: 0.75rem/3rem "微软雅黑";
        color: #ffc000;
    }
    .Cart_main-Yes-header-edit>a:last-of-type{
        display: none;
    }
    .Cart_main-Yes-commodity{
        width: 100%;
        height: 6rem;
        background: white;
        padding: 0.6rem 0.3rem;
        border-bottom: 1px solid #cacaca;
        box-sizing: border-box;
        display: flex;
        position: relative;
    }
    .Cart_main-Yes-commodity>dt>img{
        width: 6rem;
        height: 5rem;
        font-size: 0;
    }
    .Cart_main-Yes-commodity>dd{
        font: 0.8rem/0.8rem "微软雅黑";
        padding: 0.2rem 0 0 0.3rem;
        box-sizing: border-box;
        color: #979797;
    }
    .Cart_main-Yes-commodity-details{
        display: flex;
        flex-direction: column;
    }
    .Cart_main-Yes-commodity-content{
        height: 50%;
    }
    .Cart_main-Yes-commodity-content p:last-of-type{
      width: 90%;
      white-space: pre;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .Cart_main-Yes-commodity .Cart_main-Yes-commodity-name,.Cart_main-Yes-commodity .Cart_main-Yes-commodity-price{
        font: 0.8rem/0.8rem "微软雅黑";
        color: #424644;
    }
    .Cart_main-Yes-commodity-name{
        padding-bottom: 0.5rem;
    }
    .Cart_main-Yes-commodity .Cart_main-Yes-commodity-price{
        font-weight: bold;
        line-height: 1rem;
        font-size: 1rem;
    }
    .Cart_main-Yes-commodity-money{
        height: 50%;
        display: flex;
        flex-direction: column;
        justify-content: flex-end;
        padding-bottom: 0.1rem;
    }
    .Cart_main-Yes-commodity-money p{
        color: #424644;
    }
    .Cart_main-Yes-commodity-money .Cart_main-Yes-commodity-style{
        display: flex;
        align-items: center;
        width: 4rem;
        height: 1.2rem;
        background: orange;
        justify-content: center;
        border-radius: 0.2rem;
        margin-top: 0.4rem;
        font: 0.6rem/0.6rem "微软雅黑";
        color: white;
    }
    .Cart_main-Yes-commodity>.Cart_main-Yes-commodity-allNum{
        width: 4rem;
        height: 1.2rem;
        border: 1px solid #dbdbdb;
        box-sizing: border-box;
        position: absolute;
        bottom: 0.5rem;
        right: 0.3rem;
        display: flex;
        font-size: 0;
        padding: 0;
        background: white;
    }
    .Cart_main-Yes-commodity-allNum>a{
        display: block;
        width: 33%;
        height: 100%;
        border-right: 1px solid #dbdbdb;
        box-sizing: border-box;
        text-align: center;
        font: 1.5rem/1rem "微软雅黑";
        color: #7A7979;
    }
    .Cart_main-Yes-commodity-allNum>.Cart_main-Yes-commodity-num{
        width: 34%;
        font-size: 0.8rem;
        line-height: 1.2rem;
        color: #000;
    }
    .Cart_main-Yes-commodity-allNum>.Cart_main-Yes-commodity-add{
        border-right: 0;
    }
    .Cart_footer-frams{
        position: relative;
        width: 100%;
        height: 5.5rem;
    }
    .Cart_footer{
        position: fixed;
        width: 100%;
        height: 3rem;
        bottom: 2.5rem;
        display: flex;
        justify-content: space-between;
        border-top: 1px solid #cacaca;
        background: white;
        font: 0.8rem/3rem "微软雅黑";
        color: white;
        box-sizing: border-box;
        z-index: 10;
    }
    .Cart_footer-money{
        color: #ff602c;
        padding: 0.5rem 0 0 1rem;
        box-sizing: border-box;
        font: bold 1rem/1rem "微软雅黑";
    }
    .Cart_footer-pay{
        width: 6.45rem;
        height: 100%;
        text-align: center;
        background: #fe9e7f;
    }
</style>
